from django.apps import AppConfig

#定义全局调度器
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler()
class CronConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'cron'
    #django启动的时候自动启动调度器
    def ready(self):
        from django_apscheduler.jobstores import DjangoJobStore
        scheduler.add_jobstore(DjangoJobStore(), "default")
        scheduler.start()
